from typing import Optional, List
from datetime import date, datetime
from decimal import Decimal

from pydantic import BaseModel, Field, ConfigDict
from module_admin.annotation.pydantic_annotation import as_query
from pydantic.alias_generators import to_camel


class FutureAccountDailyModel(BaseModel):
    """
    期货账户资金日报表对应pydantic模型
    """

    model_config = ConfigDict(from_attributes=True, alias_generator=to_camel)

    id: Optional[int] = Field(default=None, description='主键id')
    account_code: Optional[str] = Field(default=None, description='账户代码')
    settlement_date: Optional[date] = Field(default=None, description='结算日期')
    previous_balance_day: Optional[Decimal] = Field(default=Decimal('0'), description='上日结存(逐日盯市)')
    previous_balance_trade: Optional[Decimal] = Field(default=Decimal('0'), description='上日结存(逐笔对冲)')
    daily_deposit_withdrawal: Optional[Decimal] = Field(default=Decimal('0'), description='当日存取合计')
    daily_profit_day: Optional[Decimal] = Field(default=Decimal('0'), description='当日盈亏(逐日盯市)')
    daily_balance_day: Optional[Decimal] = Field(default=Decimal('0'), description='当日结存(逐日盯市)')
    close_profit_trade: Optional[Decimal] = Field(default=Decimal('0'), description='平仓盈亏(逐笔对冲)')
    daily_balance_trade: Optional[Decimal] = Field(default=Decimal('0'), description='当日结存(逐笔对冲)')
    float_profit_trade: Optional[Decimal] = Field(default=Decimal('0'), description='浮动盈亏(逐笔对冲)')
    daily_fee: Optional[Decimal] = Field(default=Decimal('0'), description='当日手续费')
    equity: Optional[Decimal] = Field(default=Decimal('0'), description='客户权益')
    margin_used: Optional[Decimal] = Field(default=Decimal('0'), description='保证金占用')
    available_funds: Optional[Decimal] = Field(default=Decimal('0'), description='可用资金')
    risk_ratio: Optional[Decimal] = Field(default=Decimal('0'), description='风险度')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')


@as_query
class FutureAccountDailyPageQueryModel(BaseModel):
    """
    期货账户资金日报分页查询模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')
    account_code: Optional[str] = Field(default=None, description='账户代码')
    begin_date: Optional[date] = Field(default=None, description='开始日期')
    end_date: Optional[date] = Field(default=None, description='结束日期')


class DeleteFutureAccountDailyModel(BaseModel):
    """
    删除期货账户资金日报请求模型
    """

    ids: list[int] = Field(description='主键ID列表')
